package cn.xyf.eduservice.controller;


import cn.xyf.commonutils.R;
import cn.xyf.eduservice.domain.subject.OneSubject;
import cn.xyf.eduservice.service.EduSubjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author xuyinfeng
 * @since 2021-04-14
 */

@Api(tags = "课程分类管理模块")
@RestController
@RequestMapping("/eduservice/subject")
@CrossOrigin
public class EduSubjectController {

    @Autowired
    EduSubjectService eduSubjectService;

    @ApiOperation("上传课程分类Excel文件")
    @PostMapping
    public R addSubject(MultipartFile file) {
        eduSubjectService.saveSubject(file, eduSubjectService);
        return R.ok();
    }

    @ApiOperation("查询所有分类课程")
    @GetMapping("/getAllSubject")
    public R getAllSubject() {
        List<OneSubject> list = eduSubjectService.findAllSubject();
        return R.ok().data("data", list);
    }

}

